//Magnus Baunsgaard Kristensen s140168
//Jonathan Yannick Thomassen s125070

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JPanel;

public class KnapPanel1 extends JPanel {

  JButton buttonA = new JButton();
  JButton buttonB = new JButton();
  JButton buttonC = new JButton();
  JButton buttonD = new JButton();

  Konsol ejer;

  public KnapPanel1(Konsol k) {
    try {
      init();
    } catch (Exception e) {
    }
    ejer = k;
  }

  private void init() throws Exception {
    buttonA.setText("A");
    buttonB.setText("B");
    buttonC.setText("C");
    buttonD.setText("D");

    buttonA.setBounds(10, 10, 80, 50);
    buttonB.setBounds(10, 75, 80, 50);
    buttonC.setBounds(10, 140, 80, 50);
    buttonD.setBounds(10, 205, 80, 50);

    this.setLayout(null);
    this.add(buttonA);
    this.add(buttonB);
    this.add(buttonC);
    this.add(buttonD);

    buttonA.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonA_actionPerformed(e);
      }
    });

    buttonB.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonB_actionPerformed(e);
      }
    });

    buttonC.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonC_actionPerformed(e);
      }
    });

    buttonD.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        buttonD_actionPerformed(e);
      }
    });
  }

  void buttonA_actionPerformed(ActionEvent e) {
    ejer.knapInput("A");
  }

  void buttonB_actionPerformed(ActionEvent e) {
    ejer.knapInput("B");
  }

  void buttonC_actionPerformed(ActionEvent e) {
    ejer.knapInput("C");
  }

  void buttonD_actionPerformed(ActionEvent e) {
    ejer.knapInput("D");
  }
}
